#!/bin/sh

# 加载工具类
. /etc/idnewnil/utils.sh

# 自签证书
DOMAIN=$(getstr '.["domain.home"]')
OUT=/etc/self-sign/${DOMAIN}
CRT=${OUT}/self-sign.crt
KEY=${OUT}/self-sign.key
uci add cert self-signed
uci set cert.@self-signed[-1].domain=${DOMAIN}
uci set cert.@self-signed[-1].out=${OUT}
uci set uhttpd.main.cert=${CRT}
uci set uhttpd.main.key=${KEY}
uci set cert.self_signed=cert
uci set cert.self_signed.crt=${CRT}
uci set cert.self_signed.key=${KEY}
uci commit
self-sign ${DOMAIN} ${OUT}
/etc/init.d/uhttpd restart
